<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
      layout:decorate="~{admin/layout}">
<body>

<div  class="content-wrap" layout:fragment="content">
    <main id="content" class="content" role="main">
        <ol class="breadcrumb">
            <li>用户管理</li>
            <li class="active">后台用户列表</li>
        </ol>
        <section class="widget">
            <header>
                <h4>用户管理列表</h4>
                <button class="btn btn-gray" data-toggle="modal" data-target="#myModal18">
                    创建后台管理员
                </button>
                <div class="modal fade" id="myModal18" tabindex="-1" role="dialog" aria-labelledby="myModalLabel18" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                <h5 class="modal-title text-xl-center fw-bold mt" id="myModalLabel18">用户创建</h5>
                            </div>
                            <div class="modal-body bg-gray-lighter">
                                <form th:action="@{/admin/save}" id="validation-form" class="form-horizontal form-label-left" method="post">
                                    <fieldset>
                                        <legend>
                                    <span class="label label-warning  text-gray-dark mr-xs">
                                    个人
                                    </span>
                                            信息
                                        </legend>
                                        <div class="form-group row">
                                            <label class="control-label col-sm-3" for="website">
                                                登录账号
                                            </label>
                                            <div class="col-sm-9">
                                                <input type="text" id="website" name="username" class="form-control"
                                                       required="required">
                                            </div>
                                        </div>
                                        <div class="form-group row">
                                            <label class="control-label col-sm-3" for="password">
                                                登录密码
                                            </label>
                                            <div class="col-sm-9">
                                                <input type="password" id="password" name="password" class="form-control mb-sm"
                                                       data-parsley-trigger="change"
                                                       data-parsley-minlength="6"
                                                       required="required">
                                                <input type="password" id="password-r" name="password-r" class="form-control"
                                                       data-parsley-trigger="change"
                                                       data-parsley-minlength="6"
                                                       data-parsley-equalto="#password"
                                                       required="required">
                                            </div>
                                        </div>
                                    </fieldset>
                                    <div class="form-actions">
                                        <button type="submit" class="btn btn-danger btn-rounded pull-xs-right">提交</button>
                                        <button type="button" class="btn btn-gray" data-dismiss="modal">取消</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </header>
            <div class="widget-body">
                <div class="mt">
                    <table id="datatable-table" class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th>登录账号</th>
                            <th class="no-sort hidden-sm-down">联系电话</th>
                            <th class="hidden-sm-down">企业邮箱</th>
                            <th class="hidden-sm-down">公司地址</th>
                            <th>拥有权限</th>
                            <th class="no-sort">管理</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="admin:${admin}">
                            <td th:text="${admin.username}"></td>
                            <td class="hidden-sm-down" th:text="${admin.company.personPhone}"></td>
                            <td class="hidden-sm-down" th:text="${admin.company.email}"></td>
                            <td class="hidden-sm-down" th:text="${admin.company.address}"></td>
                            <td class="width-150" th:each="role : ${admin.roleList}" th:text="${role.descp}"></td>
                            <td class="width-150">
                                <div class="btn-group">
                                    <button class="btn btn-danger" data-toggle="dropdown">
                                        &nbsp; 授权 &nbsp;
                                        <i class="fa fa-caret-down"></i>
                                    </button>
                                    <ul class="dropdown-menu">
                                        <li><button onclick="common(this.value)" th:value="${admin.admin_id}" class="dropdown-item" >普通操作员</button></li>
                                        <li><button onclick="finance(this.value)" th:value="${admin.admin_id}" class="dropdown-item" >财务人员</button></li>
                                        <li><button onclick="watcher(this.value)" th:value="${admin.admin_id}" class="dropdown-item" >浏览者</button></li>
                                        <li><button onclick="deleteadmin(this.value)" th:value="${admin.admin_id}" class="dropdown-item" >
                                                <i th:href="@{/admin/delete(admin_id=${admin.admin_id})}" style="color: #C20000"  class="glyphicon glyphicon-trash">

                                                </i>
                                            </button>
                                        </li>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <script>
                        function common(id) {
                            self.location.href = "/admin/role/allocation?type=1&id=" + id;
                        }
                        function finance(id) {
                            self.location.href = "/admin/role/allocation?type=2&id=" + id;
                        }
                        function watcher(id) {
                            self.location.href = "/admin/role/allocation?type=3&id=" + id;
                        }
                        function deleteadmin(id) {
                            self.location.href = "/admin/delete?admin_id=" + id;
                        }
                    </script>
                </div>
            </div>
        </section>
    </main>
</div>
</body>
</html>